package jupitermouse.site.keytuple;

import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.operators.DataSource;


public class MyMapFunctionTest {
    public static void main(String[] args) {
        String inputPath = "file:///E:\\workroom\\learn\\flink\\demo_flink\\doc\\word.txt";

        //set env
        final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

        //read data
        DataSource<String> dataSource = env.readTextFile(inputPath);
        //transform
        try {
            dataSource.flatMap(new MyMapFunction()).groupBy(0).sum(1).print();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
